Refactor regexp & fix incompatibility + error
authorHenrik Lissner <accounts@v0.io>
Thu, 2 Jan 2020 21:41:11 +0000 (16:41 -0500)
committerGitHub <noreply@github.com>
Thu, 2 Jan 2020 21:41:11 +0000 (16:41 -0500)
which-key.el

index 74de73741eaf8a63e519ef4b316ff07d2a9ace15..c8029b7d7234af3ec410b69a19807a44dcbe1547 100644 (file)
@@ -1671,12 +1671,17 @@ and `which-key-show-docstrings' is non-nil. If
 return the docstring."
   (let* ((orig-sym (intern original))
          (doc (when (commandp orig-sym)
-                (string-trim-left
-                 (documentation orig-sym)
-                 (concat "\\(?::"
-                         "\\(?:\\(?:after\\|before\\)\\(?:-\\(?:until\\|while\\)\\)?\\|around\\|override\\|filter-\\(?:args\\|return\\)\\)"
+                (documentation orig-sym)))
+         (doc (when doc
+                (replace-regexp-in-string
+                 (concat "^\\(?::"
+                         (regexp-opt '("around" "override"
+                                       "after" "after-until" "after-while"
+                                       "before" "before-until" "before-while"
+                                       "filter-args" "filter-return"))
                          " advice: [^\n]+\n"
-                         "\\)+\n"))))
+                         "\\)+\n")
+                 "" doc)))
          (docstring (when doc
                       (which-key--propertize (car (split-string doc "\n"))
                                              'face 'which-key-docstring-face))))